#include <stdio.h>
#include "Thread.hpp"

void *thread_start(void *args)
{
    std::string workname = static_cast<const char *>(args);
    while (true)
    {
        std::cout << "新线程,我在做:" << workname << std::endl;
        sleep(1);
    }
}

void test1()
{
    Thread *thread1 = new Thread(thread_start, (void *)"add", 0);
    Thread *thread2 = new Thread(thread_start, (void *)"sub", 1);
    Thread *thread3 = new Thread(thread_start, (void *)"read", 2);
    Thread *thread4 = new Thread(thread_start, (void *)"print", 3);

    thread1->start();
    thread2->start();
    thread3->start();
    thread4->start();

    thread1->join();
    thread2->join();
    thread3->join();
    thread4->join();
}

int main()
{
    test1();
    while (true)
    {
        std::cout << "主线程:" << std::endl;
        sleep(1);
    }
    return 0;
}